package cn.stylefeng.guns.modular.api.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.bms.model.params.BmsIndustryParam;
import cn.stylefeng.guns.modular.bms.model.params.BmsPostInfoParam;
import cn.stylefeng.guns.modular.bms.model.params.BmsWelfareParam;
import cn.stylefeng.guns.modular.bms.model.result.BmsIndustryResult;
import cn.stylefeng.guns.modular.bms.model.result.BmsPostInfoResult;
import cn.stylefeng.guns.modular.bms.model.result.BmsWelfareResult;
import cn.stylefeng.guns.modular.bms.service.BmsIndustryService;
import cn.stylefeng.guns.modular.bms.service.BmsPostInfoService;
import cn.stylefeng.guns.modular.bms.service.BmsWelfareService;
import cn.stylefeng.guns.modular.ums.model.params.ChatHistoryParam;
import cn.stylefeng.guns.modular.ums.service.ChatHistoryService;
import cn.stylefeng.guns.utils.json.JsonUtils;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/api/goeasy")
@Api(tags = "goeasy消息同步接口")
@CrossOrigin
public class ApiWebhookController extends BaseController {

    @Resource
    private ChatHistoryService chatHistoryService;

    /**
     * 同步消息
     */
    @ResponseBody
    @RequestMapping(value = "/syncHistory",method = RequestMethod.POST)
    @ApiOperation(value = "同步消息", notes = "同步消息")
    public ResponseData syncHistory(String content) {
        try {
             List<ChatHistoryParam> list=JsonUtils.jsonToList(content,ChatHistoryParam.class);
            System.out.println("--------------同步消息-----------------");
            System.out.println(list.toString());
            chatHistoryService.add(list);
            return ResponseData.success();
        }catch (Exception e){
            return ResponseData.error(e.getMessage());
        }
    }


}